package ufcg.metci.huffman;


/**
 * Projeto para disciplina de Metodologia Científica - UFCG - 2012.1
 * 
 * @author Ana Clara Lacerda
 * @author Rodolfo Marinho
 *
 * Representa um nó (não folha) da árvore de Huffman
 */
public class HuffmanNode implements Comparable<HuffmanNode>{
	
	private int frequency;
	
	private HuffmanNode right;
	private HuffmanNode left;
	
	public HuffmanNode(int frequency) {
		this.frequency = frequency;
	}
	
	public HuffmanNode(HuffmanNode right, HuffmanNode left) {
		this.right = right;
		this.left = left;
		this.frequency = right.getFrequency() + left.getFrequency();
	}

	public int getFrequency() {
		return frequency;
	}

	public void setFrequency(int frequency) {
		this.frequency = frequency;
	}

	public HuffmanNode getRight() {
		return right;
	}

	public void setRight(HuffmanNode right) {
		this.right = right;
	}

	public HuffmanNode getLeft() {
		return left;
	}

	public void setLeft(HuffmanNode left) {
		this.left = left;
	}

	@Override
	public int compareTo(HuffmanNode o) {
		return frequency - o.getFrequency();
	}
	
	@Override
	public String toString() {
		return "Node : " + getFrequency();
	}
}
